<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.2/css/all.min.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css">

<script class="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"littlefxc.github.io","root":"/","images":"/images","scheme":"Mist","version":"8.2.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}};
  </script>
<meta name="description" content="[TOC] 1 编译器优化1.1 字节码是如何运行的？ 解释执行：由解释器一行一行翻译执行  优势在于没有编译的等待时间 性能相对差一些   编译执行：把字节码编译成机器码，直接执行机器码  运行效率会高很多，一般认为比解释执行快一个数量级 带来了额外的开销    那么如何查看自己的java是解释执行还是编译执行呢？ 1234$ java -versionjava version &quot;1.">
<meta property="og:type" content="article">
<meta property="og:title" content="JVM 编译器优化">
<meta property="og:url" content="http://littlefxc.github.io/2022/02/15/docs/JVM/JVM-%E7%BC%96%E8%AF%91%E5%99%A8%E4%BC%98%E5%8C%96/index.html">
<meta property="og:site_name" content="一年春又来">
<meta property="og:description" content="[TOC] 1 编译器优化1.1 字节码是如何运行的？ 解释执行：由解释器一行一行翻译执行  优势在于没有编译的等待时间 性能相对差一些   编译执行：把字节码编译成机器码，直接执行机器码  运行效率会高很多，一般认为比解释执行快一个数量级 带来了额外的开销    那么如何查看自己的java是解释执行还是编译执行呢？ 1234$ java -versionjava version &quot;1.">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/littlefxc/oss/raw/master/images/image-20210809233815237.png">
<meta property="og:image" content="https://gitee.com/littlefxc/oss/raw/master/images/image-20210809234920524.png">
<meta property="og:image" content="https://gitee.com/littlefxc/oss/raw/master/images/image-20220215160030958.png">
<meta property="og:image" content="https://gitee.com/littlefxc/oss/raw/master/images/image-20220215160113222.png">
<meta property="og:image" content="https://gitee.com/littlefxc/oss/raw/master/images/image-20220215163048392.png">
<meta property="og:image" content="https://gitee.com/littlefxc/oss/raw/master/images/image-20220215162940763.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/5b8ca757bfc34cb1ade3d2e9e32ed132.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5LiA5bm05pil5Y-I5p2l,size_20,color_FFFFFF,t_70,g_se,x_16">
<meta property="article:published_time" content="2022-02-14T22:49:00.000Z">
<meta property="article:modified_time" content="2022-05-10T01:24:00.466Z">
<meta property="article:author" content="一年春又来">
<meta property="article:tag" content="jvm">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/littlefxc/oss/raw/master/images/image-20210809233815237.png">


<link rel="canonical" href="http://littlefxc.github.io/2022/02/15/docs/JVM/JVM-%E7%BC%96%E8%AF%91%E5%99%A8%E4%BC%98%E5%8C%96/">


<script class="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>
<title>JVM 编译器优化 | 一年春又来</title>
  




  <noscript>
  <style>
  body { margin-top: 2rem; }

  .use-motion .menu-item,
  .use-motion .sidebar,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header {
    visibility: visible;
  }

  .use-motion .header,
  .use-motion .site-brand-container .toggle,
  .use-motion .footer { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle,
  .use-motion .custom-logo-image {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line {
    transform: scaleX(1);
  }

  .search-pop-overlay, .sidebar-nav { display: none; }
  .sidebar-panel { display: block; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="一年春又来" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">一年春又来</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-home"><a href="/" rel="section"><i class="home                          //首页 fa-fw"></i>首页</a></li>
        <li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="archive          //归档 fa-fw"></i>归档</a></li>
        <li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="th           //分类 fa-fw"></i>分类</a></li>
        <li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="tags                     //标签 fa-fw"></i>标签</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%BC%96%E8%AF%91%E5%99%A8%E4%BC%98%E5%8C%96"><span class="nav-text">1 编译器优化</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E5%AD%97%E8%8A%82%E7%A0%81%E6%98%AF%E5%A6%82%E4%BD%95%E8%BF%90%E8%A1%8C%E7%9A%84%EF%BC%9F"><span class="nav-text">1.1 字节码是如何运行的？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-Hotspot-%E7%9A%84%E5%8D%B3%E6%97%B6%E7%BC%96%E8%AF%91%E5%99%A8-C1"><span class="nav-text">1.2 Hotspot 的即时编译器 C1</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-Htospot-%E7%9A%84%E5%8D%B3%E6%97%B6%E7%BC%96%E8%AF%91%E5%99%A8-C2"><span class="nav-text">1.3 Htospot 的即时编译器 C2</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-4-%E5%88%86%E5%B1%82%E7%BC%96%E8%AF%91"><span class="nav-text">1.4 分层编译</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-5-%E5%88%86%E5%B1%82%E7%BC%96%E8%AF%91-JVM%E5%8F%82%E6%95%B0%E9%85%8D%E7%BD%AE%E7%A4%BA%E4%BE%8B"><span class="nav-text">1.5 分层编译- JVM参数配置示例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-6-%E5%A6%82%E4%BD%95%E6%89%BE%E5%88%B0%E7%83%AD%E7%82%B9%E4%BB%A3%E7%A0%81%EF%BC%9F%E6%80%9D%E8%B7%AF%EF%BC%9F"><span class="nav-text">1.6 如何找到热点代码？思路？</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-7-Hotspot-%E5%86%85%E7%BD%AE%E7%9A%84%E4%B8%A4%E7%B1%BB%E8%AE%A1%E6%95%B0%E5%99%A8"><span class="nav-text">1.7 Hotspot 内置的两类计数器</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-8-%E6%96%B9%E6%B3%95%E8%B0%83%E7%94%A8%E8%AE%A1%E6%95%B0%E5%99%A8%E6%B5%81%E7%A8%8B"><span class="nav-text">1.8 方法调用计数器流程</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-9-%E5%9B%9E%E8%BE%B9%E8%AE%A1%E6%95%B0%E5%99%A8%E6%B5%81%E7%A8%8B"><span class="nav-text">1.9 回边计数器流程</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-10-%E6%96%B9%E6%B3%95%E5%86%85%E8%81%94"><span class="nav-text">1.10 方法内联</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-10-1-%E4%BB%80%E4%B9%88%E6%98%AF%E6%96%B9%E6%B3%95%E5%86%85%E8%81%94%EF%BC%9F%E7%A4%BA%E4%BE%8B%EF%BC%9F"><span class="nav-text">1.10.1 什么是方法内联？示例？</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-10-2-%E5%8F%91%E7%94%9F%E6%96%B9%E6%B3%95%E5%86%85%E8%81%94%E7%9A%84%E6%9D%A1%E4%BB%B6"><span class="nav-text">1.10.2 发生方法内联的条件</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-10-3-%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95%E5%86%85%E8%81%94%E7%9A%84%E6%B3%A8%E6%84%8F%E7%82%B9%EF%BC%9A"><span class="nav-text">1.10.3 使用方法内联的注意点：</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-10-4-%E6%96%B9%E6%B3%95%E5%86%85%E8%81%94%E5%8F%AF%E8%83%BD%E5%B8%A6%E6%9D%A5%E7%9A%84%E9%97%AE%E9%A2%98"><span class="nav-text">1.10.4 方法内联可能带来的问题</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-10-5-%E5%86%85%E8%81%94%E7%9B%B8%E5%85%B3JVM%E5%8F%82%E6%95%B0"><span class="nav-text">1.10.5 内联相关JVM参数</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-10-6-%E6%96%B9%E6%B3%95%E5%86%85%E8%81%94%E6%B5%8B%E8%AF%95%E4%BB%A3%E7%A0%81"><span class="nav-text">1.10.6 方法内联测试代码</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-11-%E9%80%83%E9%80%B8%E5%88%86%E6%9E%90%E3%80%81%E6%A0%87%E9%87%8F%E6%9B%BF%E6%8D%A2%E3%80%81%E6%A0%88%E4%B8%8A%E5%88%86%E9%85%8D"><span class="nav-text">1.11 逃逸分析、标量替换、栈上分配</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#1-11-1-%E9%80%83%E9%80%B8%E5%88%86%E6%9E%90"><span class="nav-text">1.11.1 逃逸分析</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-11-2-%E6%A0%87%E9%87%8F%E6%9B%BF%E6%8D%A2"><span class="nav-text">1.11.2 标量替换</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-11-3-%E6%A0%88%E4%B8%8A%E5%88%86%E9%85%8D"><span class="nav-text">1.11.3 栈上分配</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#1-11-4-%E7%9B%B8%E5%85%B3JVM%E5%8F%82%E6%95%B0"><span class="nav-text">1.11.4 相关JVM参数</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%8F%82%E8%80%83%E8%B5%84%E6%BA%90"><span class="nav-text">2 参考资源</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">一年春又来</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">234</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">38</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">125</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://littlefxc.github.io/2022/02/15/docs/JVM/JVM-%E7%BC%96%E8%AF%91%E5%99%A8%E4%BC%98%E5%8C%96/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="一年春又来">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="一年春又来">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          JVM 编译器优化
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-02-15 06:49:00" itemprop="dateCreated datePublished" datetime="2022-02-15T06:49:00+08:00">2022-02-15</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2022-05-10 09:24:00" itemprop="dateModified" datetime="2022-05-10T09:24:00+08:00">2022-05-10</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Java/" itemprop="url" rel="index"><span itemprop="name">Java</span></a>
        </span>
    </span>

  
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <p>[TOC]</p>
<h2 id="1-编译器优化"><a href="#1-编译器优化" class="headerlink" title="1 编译器优化"></a>1 编译器优化</h2><h3 id="1-1-字节码是如何运行的？"><a href="#1-1-字节码是如何运行的？" class="headerlink" title="1.1 字节码是如何运行的？"></a>1.1 字节码是如何运行的？</h3><ul>
<li><p>解释执行：由解释器一行一行翻译执行</p>
<ul>
<li>优势在于没有编译的等待时间</li>
<li>性能相对差一些</li>
</ul>
</li>
<li><p>编译执行：把字节码编译成机器码，直接执行机器码</p>
<ul>
<li>运行效率会高很多，一般认为比解释执行快一个数量级</li>
<li>带来了额外的开销</li>
</ul>
</li>
</ul>
<p>那么如何查看自己的java是解释执行还是编译执行呢？</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ java -version</span><br><span class="line">java version <span class="string">&quot;1.8.0_251&quot;</span></span><br><span class="line">Java(TM) <span class="function">SE Runtime <span class="title">Environment</span> <span class="params">(build <span class="number">1.8</span><span class="number">.0_251</span>-b08)</span></span></span><br><span class="line"><span class="function">Java <span class="title">HotSpot</span><span class="params">(TM)</span> 64-Bit Server <span class="title">VM</span> <span class="params">(build <span class="number">25.251</span>-b08, mixed mode)</span></span></span><br></pre></td></tr></table></figure>

<p>mixed mode 代表混合执行，部分解释执行、部分编译执行。</p>
<ul>
<li><p>-Xint:设置JVM的执行模式为解释执行模式</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ java -Xint -version</span><br><span class="line">java version <span class="string">&quot;1.8.0_251&quot;</span></span><br><span class="line">Java(TM) <span class="function">SE Runtime <span class="title">Environment</span> <span class="params">(build <span class="number">1.8</span><span class="number">.0_251</span>-b08)</span></span></span><br><span class="line"><span class="function">Java <span class="title">HotSpot</span><span class="params">(TM)</span> 64-Bit Server <span class="title">VM</span> <span class="params">(build <span class="number">25.251</span>-b08, interpreted mode)</span></span></span><br></pre></td></tr></table></figure></li>
<li><p>-Xcomp:JVM优先以编译模式运行，不能编译的，以解释模式运行</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ java -Xcomp -version</span><br><span class="line">java version <span class="string">&quot;1.8.0_251&quot;</span></span><br><span class="line">Java(TM) <span class="function">SE Runtime <span class="title">Environment</span> <span class="params">(build <span class="number">1.8</span><span class="number">.0_251</span>-b08)</span></span></span><br><span class="line"><span class="function">Java <span class="title">HotSpot</span><span class="params">(TM)</span> 64-Bit Server <span class="title">VM</span> <span class="params">(build <span class="number">25.251</span>-b08, compiled mode)</span></span></span><br></pre></td></tr></table></figure></li>
<li><p>-Xmixed:以混合模式运行</p>
</li>
</ul>
<p>一般情况下，我们的代码一开始一般由解释器解释执行。但是当虚拟机发现某个方法或代码块的运行特别频繁的时候，就会认为这些代码是<strong>热点代码（如何定位？）</strong>。为了提高热点代码的执行效率，会用即使编译器（也就是JIT）把这些热点代码编译城与本地平台相关的机器码，<strong>并进行各层次的优化（操作系统的不同、CPU架构的不同）</strong></p>
<h3 id="1-2-Hotspot-的即时编译器-C1"><a href="#1-2-Hotspot-的即时编译器-C1" class="headerlink" title="1.2 Hotspot 的即时编译器 C1"></a>1.2 Hotspot 的即时编译器 C1</h3><ul>
<li>是一个简单快速的编译器</li>
<li>主要关注局部性的优化</li>
<li>适用于执行时间较短或启动性能有要求的程序。例如。GUI应用对界面启动速度就有一定要求。、</li>
<li>也被称为 Client Compiler</li>
</ul>
<h3 id="1-3-Htospot-的即时编译器-C2"><a href="#1-3-Htospot-的即时编译器-C2" class="headerlink" title="1.3 Htospot 的即时编译器 C2"></a>1.3 Htospot 的即时编译器 C2</h3><ul>
<li>是为长期运行的服务器端应用程序做性能调优的编译器</li>
<li>适用于执行时间较长或对峰值性能有要求的程序</li>
<li>也被称为是 Server Compiler</li>
</ul>
<h3 id="1-4-分层编译"><a href="#1-4-分层编译" class="headerlink" title="1.4 分层编译"></a>1.4 分层编译</h3><p>从JDK7开始，正式引入了分层编译的概念，可以细分为 5 种编译级别：</p>
<ul>
<li><ol start="0">
<li>解释执行</li>
</ol>
</li>
<li><ol>
<li>简单 C1 编译：会用 C1 编译器进行一些简单的优化，不开启 Profiling（JVM性能监控）</li>
</ol>
</li>
<li><ol start="2">
<li>受限的 C1 编译：仅执行带<strong>方法调用次数</strong>以及<strong>循环回边执行次数</strong>Profiling的 C1 编译</li>
</ol>
</li>
<li><ol start="3">
<li>完全C1编译：会执行带有所有Profiling的C1代码</li>
</ol>
</li>
<li><ol start="4">
<li>C2 编译：使用C2编译器进行优化，该级别会启用一些编译耗时较长的优化，一些情况下会根据性能监控信息进行一些非常激进的性能优化</li>
</ol>
</li>
</ul>
<p>级别越高，应用启动越慢，优化的开销越高，峰值性能也越高。</p>
<h3 id="1-5-分层编译-JVM参数配置示例"><a href="#1-5-分层编译-JVM参数配置示例" class="headerlink" title="1.5 分层编译- JVM参数配置示例"></a>1.5 分层编译- JVM参数配置示例</h3><ul>
<li>只想开启 C2：-XX:-TieredCompilation（禁用中间编译层（123层））</li>
<li>只想开启 C1：-XX:+TieredCompilation -XX:TieredStopAtLevel=1</li>
</ul>
<h3 id="1-6-如何找到热点代码？思路？"><a href="#1-6-如何找到热点代码？思路？" class="headerlink" title="1.6 如何找到热点代码？思路？"></a>1.6 如何找到热点代码？思路？</h3><ul>
<li><p>基于采样的热点探测</p>
<p>周期性检查各个线程的栈顶，如果发现某一些方法总是出现在各个栈顶，那就说明是热点代码。</p>
</li>
<li><p>基于计数器的热点探测</p>
<p>大致思路是为每一个方法甚至是代码块建立计数器，然后统计执行的次数，如果超过一定的阈值，那就说明它是热点代码。Hotspot虚拟机采用的就是基于计数器的热点探测。</p>
</li>
</ul>
<h3 id="1-7-Hotspot-内置的两类计数器"><a href="#1-7-Hotspot-内置的两类计数器" class="headerlink" title="1.7 Hotspot 内置的两类计数器"></a>1.7 Hotspot 内置的两类计数器</h3><ul>
<li><p>方法调用计数器（Invocation Counter）</p>
<p>用于统计方法被调用的次数，在不开启分层编译的情况下，在 C1 编译器下的默认阈值是 1500 次，在 C2 模式下是 10000次。也可以哦那个 -XX:CompileThreshold=X 指定阈值</p>
</li>
<li><p>回边计数器（Back Edge Counter）</p>
<ul>
<li>用于统计一个方法中循环体代码执行的次数，在字节码中遇到控制流向后跳转的指令称为“回边”（Back Edge）。在不开启分层编译的情况下，C1 编译器心爱的默认阈值 13995，C2 默认为 10700，可使用 -XX:OnStackReplacePercentage=X指定阈值</li>
<li>建立回边计数器的主要目的是为了触发 OSR （OnStackReplacement）编译，参考文档（<a target="_blank" rel="noopener" href="https://www.zhihu.com/question/45910849/answer/100636125">https://www.zhihu.com/question/45910849/answer/100636125</a>）</li>
</ul>
</li>
<li><p>当开启分层编译时，JVM会根据当前编译的方法数以及编译线程数来动态调整阈值，-XX:CompileThreshold、-XX:OnStackReplacePercentage 都会失效。</p>
</li>
</ul>
<h3 id="1-8-方法调用计数器流程"><a href="#1-8-方法调用计数器流程" class="headerlink" title="1.8 方法调用计数器流程"></a>1.8 方法调用计数器流程</h3><p><img src="https://gitee.com/littlefxc/oss/raw/master/images/image-20210809233815237.png" alt="image-20210809233815237"></p>
<p>如果不做任何设置，方法调用次数统计的并不是方法被调用的绝对次数，而是一个相对的执行频，即一段时间之内方法被调用的次数。当超过一定的时间限度，如果方法的调用次数荏苒不足以让它提交给及时编译器编译，那这个方法的调用计数器就会减少一半，这个过程称为方法调用计数器热度的衰减，而这段时间就称为此方法统计的半衰周期。进行热度衰减的动作是在虚拟机进行垃圾手机是顺便进行的，可以使用虚拟机参数-XX:-UseCounterDecay来关闭热度衰减，让方法计数器统计方法调用的绝对次数，这样，只要系统运行时间足够长，绝大部分方法都会被编译成本地代码。另外，可以使用-XX:CounterHalfLifeTime参数设置半衰周期的时间，单位是秒。</p>
<h3 id="1-9-回边计数器流程"><a href="#1-9-回边计数器流程" class="headerlink" title="1.9 回边计数器流程"></a>1.9 回边计数器流程</h3><p><img src="https://gitee.com/littlefxc/oss/raw/master/images/image-20210809234920524.png" alt="image-20210809234920524"></p>
<h3 id="1-10-方法内联"><a href="#1-10-方法内联" class="headerlink" title="1.10 方法内联"></a>1.10 方法内联</h3><h4 id="1-10-1-什么是方法内联？示例？"><a href="#1-10-1-什么是方法内联？示例？" class="headerlink" title="1.10.1 什么是方法内联？示例？"></a>1.10.1 什么是方法内联？示例？</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.example;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">InlineTest1</span> </span>&#123;</span><br><span class="line">  <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">add1</span><span class="params">(<span class="keyword">int</span> x1, <span class="keyword">int</span> x2, <span class="keyword">int</span> x3, <span class="keyword">int</span> x4)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> add2(x1, x2) + add2(x3, x4);</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">add2</span><span class="params">(<span class="keyword">int</span> x1, <span class="keyword">int</span> x2)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> x1 + x2;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 内联后</span></span><br><span class="line">  <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">addInline</span><span class="params">(<span class="keyword">int</span> x1, <span class="keyword">int</span> x2, <span class="keyword">int</span> x3, <span class="keyword">int</span> x4)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">return</span> x1 + x2 + x3 + x4;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><strong>所谓的方法内联就是把目标方法的代码复制到发起调用的方法之中，避免发生真实的方法调用，从而减少压栈和出栈的作用</strong></p>
<h4 id="1-10-2-发生方法内联的条件"><a href="#1-10-2-发生方法内联的条件" class="headerlink" title="1.10.2 发生方法内联的条件"></a>1.10.2 发生方法内联的条件</h4><ol>
<li><p>方法体足够小</p>
<p>热点方法：如果方法体小于325字节会尝试内联，可用 <code>-XX:FreqInlineSize</code> 修改方法体大小。</p>
<p>非热点方法：如果方法体小于35字节，也会尝试内联，可用<code>-XX:MaxInlineSize</code>修改大小。</p>
</li>
<li><p>被调用方法运行时的实现可唯一确定</p>
<p>static方法、private方法及final方法，JIT可以唯一确定具体的实现代码。</p>
<p>public的实例方法，指向的实现可能是自身、父类、子类的代码，当且仅当JIT能够唯一确定方法的具体实现时，才有可能完成内联。</p>
</li>
</ol>
<h4 id="1-10-3-使用方法内联的注意点："><a href="#1-10-3-使用方法内联的注意点：" class="headerlink" title="1.10.3 使用方法内联的注意点："></a>1.10.3 使用方法内联的注意点：</h4><ol>
<li>尽量让方法体小一点；</li>
<li>尽量使用 final、private、static关键字修饰方法，避免因为多态，需要对方法做额外检查；</li>
<li>在某些场景下，可通过JVM 参数修改阈值，从而让更多方法内联。</li>
</ol>
<h4 id="1-10-4-方法内联可能带来的问题"><a href="#1-10-4-方法内联可能带来的问题" class="headerlink" title="1.10.4 方法内联可能带来的问题"></a>1.10.4 方法内联可能带来的问题</h4><p>内联是用空间换时间的一种做法，也就是及时编译器在方法调用期间把方法调用连接在一起，但是经过内联的代码会变多，而增加的代码量取决于方法的调用次数以及方法本身的大小。</p>
<p>在一些极端情况下，内联可能会导致</p>
<ul>
<li>CodeCache（热点代码的缓存区，及时编译代码和本地方法代码）的溢出，导致JVM退化成解释执行模式；</li>
</ul>
<h4 id="1-10-5-内联相关JVM参数"><a href="#1-10-5-内联相关JVM参数" class="headerlink" title="1.10.5 内联相关JVM参数"></a>1.10.5 内联相关JVM参数</h4><p><img src="https://gitee.com/littlefxc/oss/raw/master/images/image-20220215160030958.png" alt="image-20220215160030958"></p>
<p><img src="https://gitee.com/littlefxc/oss/raw/master/images/image-20220215160113222.png" alt="image-20220215160113222"></p>
<h4 id="1-10-6-方法内联测试代码"><a href="#1-10-6-方法内联测试代码" class="headerlink" title="1.10.6 方法内联测试代码"></a>1.10.6 方法内联测试代码</h4><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">InlineTest</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">final</span> <span class="keyword">static</span> Logger log = LoggerFactory.getLogger(InlineTest.class);</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">long</span> cost = compute();</span><br><span class="line">        log.info(<span class="string">&quot;执行花费 &#123;&#125; ms&quot;</span>, cost);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">long</span> <span class="title">compute</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">long</span> start = System.currentTimeMillis();</span><br><span class="line">        <span class="keyword">int</span> result;</span><br><span class="line">        Random random = <span class="keyword">new</span> Random();</span><br><span class="line">        <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i&lt; <span class="number">10000000</span>; i++) &#123;</span><br><span class="line">            <span class="keyword">int</span> a = random.nextInt();</span><br><span class="line">            <span class="keyword">int</span> b = random.nextInt();</span><br><span class="line">            <span class="keyword">int</span> c = random.nextInt();</span><br><span class="line">            <span class="keyword">int</span> d = random.nextInt();</span><br><span class="line">            result = add1(a, b, c, d);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">long</span> end = System.currentTimeMillis();</span><br><span class="line">        <span class="keyword">return</span> end - start;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">add1</span><span class="params">(<span class="keyword">int</span> n1, <span class="keyword">int</span> n2, <span class="keyword">int</span> n3, <span class="keyword">int</span> n4)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> add2(n1, n2) + add2(n3, n4);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">int</span> <span class="title">add2</span><span class="params">(<span class="keyword">int</span> n1, <span class="keyword">int</span> n2)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> n1 + n2;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>内联启动JVM参数：<code>-XX:+UnlockDiagnosticVMOptions -XX:+PrintInlining</code></p>
<p><img src="https://gitee.com/littlefxc/oss/raw/master/images/image-20220215163048392.png" alt="image-20220215163048392"></p>
<p>不内联启动JVM参数：<code>-XX:+UnlockDiagnosticVMOptions -XX:+PrintInlining -XX:+FreqInlineSize=1</code></p>
<p><img src="https://gitee.com/littlefxc/oss/raw/master/images/image-20220215162940763.png" alt="image-20220215162940763"></p>
<p>但是，一般来说不建议使用这些JVM参数，默认的就好，现代JVM是相当智能的。</p>
<h3 id="1-11-逃逸分析、标量替换、栈上分配"><a href="#1-11-逃逸分析、标量替换、栈上分配" class="headerlink" title="1.11 逃逸分析、标量替换、栈上分配"></a>1.11 逃逸分析、标量替换、栈上分配</h3><h4 id="1-11-1-逃逸分析"><a href="#1-11-1-逃逸分析" class="headerlink" title="1.11.1 逃逸分析"></a>1.11.1 逃逸分析</h4><p>逃逸分析：分析变量能否逃出它的作用域。</p>
<p>可以细分为 4 种场景：</p>
<ol>
<li>全局变量赋值逃逸</li>
<li>方法返回值逃逸</li>
<li>实例引用逃逸</li>
<li>线程逃逸<ul>
<li>赋值给类变量或可以在其他线程中访问的实例变量</li>
</ul>
</li>
</ol>
<p>代码示例：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> fengxuechao</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@date</span> 2022/2/15</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">EscapeTest1</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> SomeClass someClass;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 全局变量赋值逃逸</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">globalVariablePointerEscape</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        someClass = <span class="keyword">new</span> SomeClass();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 方法返回值逃逸</span></span><br><span class="line"><span class="comment">     * someMethod() &#123;</span></span><br><span class="line"><span class="comment">     *     SomeClass someClass = methodPointerEscape();</span></span><br><span class="line"><span class="comment">     * &#125;</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> SomeClass <span class="title">methodPointerEscape</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">new</span> SomeClass();</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">/**</span></span><br><span class="line"><span class="comment">     * 实例引用传递逃逸</span></span><br><span class="line"><span class="comment">     */</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">instancePassPointerEscape</span><span class="params">()</span> </span>&#123;</span><br><span class="line">        <span class="keyword">this</span>.methodPointerEscape()</span><br><span class="line">                .printClassName(<span class="keyword">this</span>);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">SomeClass</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">printClassName</span><span class="params">(EscapeTest1 escapeTest)</span> </span>&#123;</span><br><span class="line">        System.out.println(escapeTest.getClass().getName());</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>JVM 会针对以上4种场景进行分析，然后会为对象做一个<strong>逃逸状态标识</strong>，一个对象主要有 3 种逃逸状态标识：</p>
<ul>
<li>全局级别逃逸：一个对象可能从方法或者当前线程中逃逸，主要有以下几种场景：<ol>
<li>对象被作为方法的返回值；</li>
<li>对象作为静态字段（static field）或者成员变量（field）；</li>
<li>如果重写了某个类的 <code>finialze()</code>方法，那么这个类的对象都会被标记为全局逃逸状态并且一定会放在堆内存中。</li>
</ol>
</li>
<li>参数级别逃逸<ol>
<li>对象被作为参数传递给一个方法，但是在这个方法之外无法访问/对其他线程不可见；</li>
</ol>
</li>
<li>无逃逸状态：一个对象不会逃逸</li>
</ul>
<h4 id="1-11-2-标量替换"><a href="#1-11-2-标量替换" class="headerlink" title="1.11.2 标量替换"></a>1.11.2 标量替换</h4><p>标量：不能被进一步分解的量</p>
<ul>
<li>基础数据类型</li>
<li>对象引用</li>
</ul>
<p>聚合量：可以进一步分解的量</p>
<ul>
<li>字符串</li>
</ul>
<p>那么什么是标量替换呢？逃逸分析确定该对象不会被外部访问，并且对象可以进一步被分解，JVM不会创建该对象，而是创建它的成员变量来代替。</p>
<p>代码展示：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Person</span> </span>&#123;</span><br><span class="line">    <span class="keyword">int</span> id;</span><br><span class="line">    <span class="keyword">int</span> age;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">    Person person = <span class="keyword">new</span> Person();</span><br><span class="line">    person.id = <span class="number">1</span>;</span><br><span class="line">    person.age = <span class="number">18</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 上面这段代码，标量替换后，原本的对象就不用分配内存空间了，就会优化成如下所示：</span></span><br><span class="line">    <span class="keyword">int</span> id = <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">int</span> age = <span class="number">18</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>JVM 参数：<code>-XX:+EliminateAllocaions</code> 开启标量替换（JDK8 默认开启）</p>
<h4 id="1-11-3-栈上分配"><a href="#1-11-3-栈上分配" class="headerlink" title="1.11.3 栈上分配"></a>1.11.3 栈上分配</h4><p>在 Java 中，绝大多数对象都是放在堆里面的，当对象无用时，由垃圾回收器回收。</p>
<p>栈上分配，顾名思义，就是通过逃逸分析，能够确认对象不会被外部访问，就在栈上分配对象，在栈上分配对象，就可以在栈帧出栈的时候销毁对象了，通过栈上分配就可以降低垃圾回收的压力。</p>
<h4 id="1-11-4-相关JVM参数"><a href="#1-11-4-相关JVM参数" class="headerlink" title="1.11.4 相关JVM参数"></a>1.11.4 相关JVM参数</h4><p><img src="https://img-blog.csdnimg.cn/5b8ca757bfc34cb1ade3d2e9e32ed132.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5LiA5bm05pil5Y-I5p2l,size_20,color_FFFFFF,t_70,g_se,x_16" alt="image-20220215212537078"></p>
<h2 id="2-参考资源"><a href="#2-参考资源" class="headerlink" title="2 参考资源"></a>2 参考资源</h2>
    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/jvm/" rel="tag"># jvm</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2022/02/11/docs/%E5%BE%AE%E6%9C%8D%E5%8A%A1/Feign/" rel="prev" title="Feign">
                  <i class="fa fa-chevron-left"></i> Feign
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2022/02/25/docs/MySQL/SQL%E8%AF%AD%E5%8F%A5%E5%9C%A8MySQL%E4%B8%AD%E7%9A%84%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B/" rel="next" title="SQL语句在MySQL中的执行流程">
                  SQL语句在MySQL中的执行流程 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>







<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      const commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">一年春又来</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/mist/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
<script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>

  
<script src="/js/local-search.js"></script>






  





</body>
</html>
